package org.nepu.scr.indexrate.converter.drillingrate.keydevice.fireextinguishersystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.fireextinguishersystem.FireExtinguisher;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class FireExtinguisherConverter implements AttributeConverter<FireExtinguisher, String> {
    @Override
    public String convertToDatabaseColumn(FireExtinguisher fireExtinguisher) {
        return JSONUtil.toJsonStr(fireExtinguisher);
    }

    @Override
    public FireExtinguisher convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, FireExtinguisher.class);
    }
}
